"""
患者健康问卷抑郁量表（PHQ-9）是一种常用的自评量表，用于评估抑郁症状的严重程度。
PHQ-9包含9个问题，每个问题的得分范围是0到3分，总分范围是0到27分。根据总分，可以将抑郁症状的严重程度分为几个等级。
"""
class PHQ9:
    def __init__(self, answers):
        self.answers = answers
        self.total_score = 0

    def calculate_score(self):
        self.total_score = sum(int(self.answers[f'q{i}']) for i in range(1, 10))

    def get_severity(self):
        if self.total_score <= 4:
            return '无或极少抑郁症状'
        elif 5 <= self.total_score <= 9:
            return '轻度抑郁'
        elif 10 <= self.total_score <= 14:
            return '中度抑郁'
        elif 15 <= self.total_score <= 19:
            return '中重度抑郁'
        else:
            return '重度抑郁'

    def get_scores(self):
        return self.total_score, self.get_severity()

# # 示例使用
# answers = {
#     'q1': '3',
#     'q2': '2',
#     'q3': '1',
#     'q4': '0',
#     'q5': '2',
#     'q6': '1',
#     'q7': '3',
#     'q8': '2',
#     'q9': '1'
# }
#
# phq9 = PHQ9(answers)
# phq9.calculate_score()
# total_score, severity = phq9.get_scores()
# print("Total Score:", total_score)
# print("Severity:", severity)